package com.wan37.logic.domain.vo;

import com.wan37.common.uuid.UUIDUtil;
import com.wan37.logic.domain.entity.UserWeaponryDO;
import com.wan37.logic.service.cache.WeaponryServiceCache;
import com.wan37.logic.tradingshop.domain.vo.TradingShopVO;
import com.wan37.protobuf.constant.BackpackLabel;

import java.util.concurrent.ConcurrentHashMap;

/**
 * @author : luoyong
 * @date : 2020-06-17 10:30
 **/
public class WeaponryVO extends BackpackVO {

    private String selfWeaponryId;
    private Integer durability;
    private Integer level;
    private String usage;
    private String part;
    private String profession;

    public WeaponryVO() {
    }

    public WeaponryVO(WeaponryVO weaponryVO){
        setUsage(BackpackLabel.WEAPONRY_UNUSED);
        setMaxRepetition(weaponryVO.getMaxRepetition());
        setName(weaponryVO.getName());
        setLabel(BackpackLabel.WEAPONRY);
        setSelfWeaponryId(UUIDUtil.getUUID());
        setLevel(1);
        setDurability(100);
        setBackpackId(weaponryVO.getBackpackId());
        setNumberMap(new ConcurrentHashMap<>());
        setPart(weaponryVO.getPart());
        setProfession(weaponryVO.getProfession());
        weaponryVO.getNumberMap().forEach((s, l) -> getNumberMap().put(s, l));
    }

    public WeaponryVO(UserWeaponryDO userWeaponryDO) {
        setBackpackId(userWeaponryDO.getWeaponryId());
        setDurability(userWeaponryDO.getDurability());
        setLevel(userWeaponryDO.getLevel());
        setSelfWeaponryId(userWeaponryDO.getSelfWeaponryId());
        setUsage(userWeaponryDO.getUsage());
    }
    public WeaponryVO(TradingShopVO tradingShopVO){
        setBackpackId(tradingShopVO.getBackpackId());
        setLevel(tradingShopVO.getLevel());
        setLabel(BackpackLabel.WEAPONRY);
    }


    public String getSelfWeaponryId() {
        return selfWeaponryId;
    }

    public void setSelfWeaponryId(String selfWeaponryId) {
        this.selfWeaponryId = selfWeaponryId;
    }

    public Integer getDurability() {
        return durability;
    }

    public void setDurability(Integer durability) {
        this.durability = durability;
    }

    public Integer getLevel() {
        return level;
    }

    public void setLevel(Integer level) {
        this.level = level;
    }

    public String getUsage() {
        return usage;
    }

    public void setUsage(String usage) {
        this.usage = usage;
    }

    public String getPart() {
        return part;
    }

    public void setPart(String part) {
        this.part = part;
    }

    public String getProfession() {
        return profession;
    }

    public void setProfession(String profession) {
        this.profession = profession;
    }

    @Override
    public String toString() {
        return "WeaponryVO{" +
                "selfWeaponryId='" + selfWeaponryId + '\'' +
                ", durability=" + durability +
                ", level=" + level +
                ", usage=" + usage +
                '}';
    }
}
